package com.structurizr.view;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

public class BrandingTests {

    private Branding branding;

    @BeforeEach
    public void setUp() {
        this.branding = new Branding();
    }

    @Test
    void setLogo_WithAUrl() {
        branding.setLogo("https://structurizr.com/static/img/structurizr-logo.png");
        assertEquals("https://structurizr.com/static/img/structurizr-logo.png", branding.getLogo());
    }

    @Test
    void setLogo_WithAUrlThatHasATrailingSpace() {
        branding.setLogo("https://structurizr.com/static/img/structurizr-logo.png ");
        assertEquals("https://structurizr.com/static/img/structurizr-logo.png", branding.getLogo());
    }

    @Test
    void setLogo_WithADataUri() {
        branding.setLogo("");
        assertEquals("", branding.getLogo());
    }

    @Test
    void setLogo_ThrowsAnIllegalArgumentException_WhenAnInvalidUrlIsSpecified() {
        assertThrows(IllegalArgumentException.class, () -> {
            branding.setLogo("htt://blah");
        });
    }

    @Test
    void setLogo_DoesNothing_WhenANullUrlIsSpecified() {
        branding.setLogo(null);
        assertNull(branding.getLogo());
    }

    @Test
    void setLogo_DoesNothing_WhenAnEmptyUrlIsSpecified() {
        branding.setLogo(" ");
        assertNull(branding.getLogo());
    }

}
